package com.example.demo1122.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo1122.entity.Class;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2023-12-11
 */
@Mapper
public interface ClassMapper extends BaseMapper<Class> {


    @Select("SELECT COUNT(*) FROM class WHERE classID = #{classID}")
    int isClassIDExists(Integer classID);

    @Update("UPDATE class SET className=#{className}, teacherID=#{teacherID},courseID=#{courseID} WHERE classID=#{classID}")
    void update(Class class1);

    @Insert("INSERT INTO class(className,teacherID,courseID) values (#{className},#{teacherID},#{courseID})")
    @Options(useGeneratedKeys = true, keyProperty = "classID")
    int insert(Class class1);
    @Select( "SELECT * FROM class WHERE teacherID = #{teacherID}")
    List<Class> selectclassByTeacherId(String teacherID);

    @ResultMap("classResultMap")
    Page<Class> findPage(Page<Class> page, Integer classID, String className, String teacherID, Integer courseID);

    Class classInfo(Integer classID);

    List<Class> getClassByStudentID(String studentID);
}
